package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏西西
 * Date: 2023-10-13
 * Time: 9:42
 */
public class IOD6 {
    //使用字节流来读取文件
    public static void main(String[] args) throws IOException {
        InputStream inputStream = new FileInputStream("f:/test.txt");

//        while(true){
//            int b = inputStream.read();
//            if(b == -1){
//                break;
//            }
//            System.out.println(""+(byte)b);
//
//        }
//        inputStream.close();
//    }
        while (true) {
            byte[] buffer = new byte[1024];
            int len = inputStream.read(buffer);
            if (len == -1) {
                break;
            }
            for (int i = 0; i < len; i++) {
                System.out.printf("%x\n", buffer[i]);
            }
        }
        inputStream.close();
    }
}
